const { ModuleFederationPlugin } = require('webpack').container

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' 
    ? 'https://cdn.example.com/order-app/' 
    : 'http://localhost:8082/',
  devServer: {
    port: 8082
  },
  configureWebpack: {
    plugins: [
      new ModuleFederationPlugin({
        name: 'orderApp',
        filename: 'remoteEntry.js',
        library: {
          type: 'var',
          name: 'orderApp'
        },
        exposes: {
          './OrderList': './src/components/OrderList.vue'
        },
        shared: {
          vue: {
            singleton: true,
            requiredVersion: require('./package.json').dependencies.vue
          },
          'vue-router': {
            singleton: true,
            requiredVersion: require('./package.json').dependencies['vue-router']
          }
        }
      })
    ],
    optimization: {
      runtimeChunk: false,
      splitChunks: false
    }
  }
}